﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using KTXD.Data;
using KTXD.Entities;
using System.Threading;

namespace UserKTXD
{
    public partial class Thu_Vien_Anh : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Pager1.CurrentIndex = 1;
                Bind_Data(Pager1.CurrentIndex);
            }
        }

        protected void Bind_Data(int PageNo)
        {
            int TotalRows = 0;
            string WhereClause = "1=1 and TrangThai=1";
            TList<BoSuuTap> TList_Menu = DataRepository.BoSuuTapProvider.GetPaged(WhereClause, "Id DESC", PageNo - 1, Pager1.PageSize, out TotalRows);
            drpThuVienAnh.DataSource = TList_Menu;
            drpThuVienAnh.DataBind();
            Pager1.ItemCount = TotalRows;
            if (TotalRows <= Pager1.PageSize)
                Pager1.Visible = false;
            else
                Pager1.Visible = true;
        }

        protected void Pager1_Command(object sender, CommandEventArgs e)
        {
            Thread.Sleep(1000);
            int currnetPageIndex = Convert.ToInt32(e.CommandArgument);
            Pager1.CurrentIndex = currnetPageIndex;
            Bind_Data(currnetPageIndex);
        }


        public string GetDienGiai(object Char)
        {
            int i = Convert.ToInt32(Char.ToString());
            TList<HinhAnh> TList_HinhAnh = DataRepository.HinhAnhProvider.GetByIdBoSuuTap(i);
            if (TList_HinhAnh.Count > 0)
                return TList_HinhAnh[0].Ten;
            else return "";
        }

        public string GetTieuDe(object Char)
        {
            string s = Char.ToString();
            return Common.ConvertToUnSign(s);
        }
    }
}